package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.nursing.domain.Elder;
import com.zzyl.nursing.dto.MemberDataDayDto;
import com.zzyl.nursing.dto.UserDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;


    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo loginVo = familyMemberService.login(dto);
        return success(loginVo);
    }

    @PostMapping("/add")
    @ApiOperation("绑定家人")
    public AjaxResult bindMember(@RequestBody UserDto dto){
        familyMemberService.insertFamilyMember(dto);
        return success();
    }

    @GetMapping("/my")
    @ApiOperation("查询家人列表")
    public AjaxResult listMemberElder(){
        List<MemberElderVo> listVo = familyMemberService.listMemberElder();
        return success(listVo);
    }

    @GetMapping("/list-by-page")
    @ApiOperation("查询看家人列表")
    public AjaxResult listByPage()
    {
        startPage();
        List<ElderMemberDetailVo> list = familyMemberService.selectElderList();
        return success(list);
    }

    @GetMapping("/queryServiceProperties/{iotId}")
    @ApiOperation("查询健康数据")
    public AjaxResult queryingHealthData(@PathVariable String iotId)
    {
        List<MemberPropertiesDataVo> list = familyMemberService.queryServiceProperties(iotId);
        return success(list);
    }

    @GetMapping("/queryDeviceDataListByDay")
    @ApiOperation("按天统计")
    public AjaxResult queryDeviceDataListByDay(MemberDataDayDto dto)
    {
        List<MemberDataDayVo> list = familyMemberService.queryDeviceDataListByDay(dto);
        return success(list);
    }

    @GetMapping("/queryDeviceDataListByWeek")
    @ApiOperation("按周统计")
    public AjaxResult queryDeviceDataListByWeek(MemberDataDayDto dto)
    {
        List<MemberDataDayVo> list = familyMemberService.queryDeviceDataListByWeek(dto);
        return success(list);
    }
}
